<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/9/24
  Time: 15:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.6.0.js"></script>
</head>
<body>
    <div id="jb">
        <button>对象的解析==javabean</button>
        <p></p>
    </div>
    <script>
        $("#jb>button").click(function () {
            $.getJSON(
                "jack?method=javaBean",
                function (data) {
                    console.log(data);
                    $("#jb>p").append(data.sid+":"+data.sname+":"+ data.gender
                        +":"+data.sbir+":"+data.hobby+":"+data.photo)
                }
            )
        })
    </script>
    <div id="list">
        <button>集合的解析==List</button>
        <table border="1" cellspacing="0" width="600px">
        </table>
    </div>
    <script>
        $("#list>button").click(function () {
            $.getJSON(
                "jack?method=stuList",
                function (data) {
                    console.log(data);
                    // 对于对象的解析
                    $(data).each(function () {
                        $("#list>table").append("<tr>\n" +
                            "                <td>" + this.sid + "</td>\n" +
                            "                <td>" + this.sname + "</td>\n" +
                            "                <td>" + this.gender + "</td>\n" +
                            "                <td>" + this.sbir + "</td>\n" +
                            "                <td>" + this.hobby + "</td>\n" +
                            "                <td>" + this.photo + "</td>\n" +
                            "            </tr>");
                    })

                }
            )
        });
    </script>

</body>
</html>
